	/*

	默认自动接起时间为4秒
	默认自动刷新时间为30分钟
	自动刷新和自动接起均为自动开启
	如果停止后需要重新启用仅需复制最后三行代码

	*/

	function checkOnline(){
		const now = new Date();
		let isOnline = navigator.onLine;
		if(isOnline.toString() == "true"){
			//console.log(now + "网络连接正常 = " + isOnline.toString());
			//pass
		}else{
			console.warn(now + "网络异常" + isOnline.toString());
			alert(now + "网络异常，请及时处理。");
		}

	}

	const connected_button = document.querySelector("#app > div > div.scmcc-layout-frame.theme-bg-gray-color > div.scmcc-layout-frame-right > div.scmcc-header > div.scmcc-header-center > div.cinccbar > ul > li:nth-child(4) > button");
	const busy_button = document.querySelector("#app > div > div.scmcc-layout-frame.theme-bg-gray-color > div.scmcc-layout-frame-right > div.scmcc-header > div.scmcc-header-center > div.cinccbar > ul > li:nth-child(2) > button");
	const free_button = document.querySelector("#app > div > div.scmcc-layout-frame.theme-bg-gray-color > div.scmcc-layout-frame-right > div.scmcc-header > div.scmcc-header-center > div.cinccbar > ul > li:nth-child(3) > button");


	function autoClick() {
	if (connected_button.disabled) {
		console.log("接听按钮未亮起");
	}else {
		console.log("接听按钮亮起");
		connected_button.click();
	}}

	let autoRefresh_counter = 0;
	function autoRefresh(){
		autoRefresh_counter += 1;

		//检测状态
		if(busy_button.disabled.toString() == "true"){
			console.log("当前状态忙,不执行");
		}else{
			busy_button.click();
			setTimeout(() => { free_button.click(); }, 1000);
			console.log("当前自动刷新共执行了"+ autoRefresh_counter+"次")
		}
	}


	let button_myEndPhoneCallButton = document.createElement("button");
	button_myEndPhoneCallButton.innerHTML = "结束自动接话"; 
	button_myEndPhoneCallButton.id = "my_End_Phone_Call_Button"; 
	document.querySelector("#app > div > div.scmcc-layout-frame.theme-bg-gray-color > div.scmcc-layout-frame-right > div.scmcc-header > div.scmcc-header-center > div.cinccbar > ul > li.callWrapper > div.callWapper-center > div:nth-child(2)").appendChild(button_myEndPhoneCallButton);

	document.getElementById('my_End_Phone_Call_Button').addEventListener('click', function() {
		clearInterval(autoAnswerInterval)
	    alert('结束自动接话');
	});

	/*
	let button_mystartPhoneCallButton = document.createElement("button");
	button_mystartPhoneCallButton.innerHTML = "开始自动接话"; 
	button_mystartPhoneCallButton.id = "start_phoneCall_Button"; 
	document.querySelector("#app > div > div.scmcc-layout-frame.theme-bg-gray-color > div.scmcc-layout-frame-right > div.scmcc-header > div.scmcc-header-center > div.cinccbar > ul > li.callWrapper > div.callWapper-center > div:nth-child(2)").appendChild(button_mystartPhoneCallButton);


	document.getElementById('start_phoneCall_Button').addEventListener('click', function() {
		var autoAnswerInterval = setInterval(autoClick, 4000);
	    alert('开始自动接话');
	});
	*/
	let button_endMyRefreshButton = document.createElement("button");
	button_endMyRefreshButton.innerHTML = "停止自动刷新"; 
	button_endMyRefreshButton.id = "btn_endMyRefreshButton"; 
	document.querySelector("#app > div > div.scmcc-layout-frame.theme-bg-gray-color > div.scmcc-layout-frame-right > div.scmcc-header > div.scmcc-header-center > div.cinccbar > ul > li.callWrapper > div.callWapper-center > div:nth-child(2)").appendChild(button_endMyRefreshButton);


	document.getElementById('btn_endMyRefreshButton').addEventListener('click', function() {
		clearInterval(autoRefreshInterval)
	    alert('停止刷新心跳');
	});

	var autoAnswerInterval = setInterval(autoClick, 4000);
	var autoRefreshInterval = setInterval(autoRefresh, 1800000);
	var checkOnlineInterval = setInterval(checkOnline, 1000)
